package com.zhenmaitang.clinic_sys.entity;

import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;

/**
 * URI权限实体类 - 接口级别的权限控制
 */
@Schema(description = "URI权限实体", example = "接口权限信息")

public class UriPermission {
    @Schema(description = "权限ID", example = "1")
    private Integer id;

    @Schema(description = "URI路径", example = "/api/users", requiredMode = Schema.RequiredMode.REQUIRED)
    private String uri;         // URI路径，如：/api/users, /api/departments/*
    
    @Schema(description = "HTTP方法", example = "GET", allowableValues = {"GET", "POST", "PUT", "DELETE", "PATCH"})
    private String method;      // HTTP方法，如：GET, POST, PUT, DELETE
    
    @Schema(description = "权限代码", example = "USER_READ", requiredMode = Schema.RequiredMode.REQUIRED)
    private String permissionCode; // 权限代码，如：USER_READ, USER_WRITE
    
    @Schema(description = "权限描述", example = "用户查询权限")
    private String description; // 描述
    
    @Schema(description = "是否启用", example = "true", defaultValue = "true")
    private Boolean enabled;
    
    @Schema(description = "创建时间", example = "2024-01-15 10:30:00")
    private LocalDateTime createTime;
    
    @Schema(description = "更新时间", example = "2024-01-15 14:20:00")
    private LocalDateTime updateTime;

    // 构造函数
    public UriPermission() {}

    public UriPermission(String uri, String method, String permissionCode, String description) {
        this.uri = uri;
        this.method = method;
        this.permissionCode = permissionCode;
        this.description = description;
        this.enabled = true;
        this.createTime = LocalDateTime.now();
        this.updateTime = LocalDateTime.now();
    }

    // Getter和Setter方法
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getPermissionCode() {
        return permissionCode;
    }

    public void setPermissionCode(String permissionCode) {
        this.permissionCode = permissionCode;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Boolean getEnabled() {
        return enabled;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public String toString() {
        return "UriPermission{" +
                "id=" + id +
                ", uri='" + uri + '\'' +
                ", method='" + method + '\'' +
                ", permissionCode='" + permissionCode + '\'' +
                ", description='" + description + '\'' +
                ", enabled=" + enabled +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
}